package com.sf.admin.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.sf.admin.mapper.RoleMapper;
import com.sf.admin.model.po.Role;
import com.sf.admin.model.vo.Msg;
import com.sf.admin.service.RoleService;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

	@Autowired
	private RoleMapper roleMapper;

	@Override
	public List<Role> selectList() {
		return roleMapper.selectList(null);
	}

	@Override
	public List<Role> selectPages(Integer pageNum, Integer sizes) {
		RowBounds rowBounds = new RowBounds();
		EntityWrapper<Role> wrapper = new EntityWrapper<>();
		List<Role> roleList = roleMapper.selectPage(rowBounds, wrapper);
		return roleList;
	}

	@Override
	public Msg insert(Role role) {
		Integer r = roleMapper.insert(role);
		return r > 0 ? Msg.success() : Msg.fail();
	}
}
